package com.jiangcheng.demo.mapper;

import com.jiangcheng.demo.entity.User;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author admin
 * @since 2021-07-15
 */
public interface UserMapper extends BaseMapper<User> {
    /**
     * 和Mybatis使用方法一致
     * @param username
     * @return
     */

    @Select("SELECT * FROM user where username = #{username}")
    public User selectByName(@Param("username") String username);
    @Select("SELECT * FROM user where email = #{email}")
    public User selectByEmail(@Param("email") String email);
    // 根据用户id 添加用户头像路径
    @Update("UPDATE user SET u_pic = #{pic_path} where id = #{uId}")
    public Integer UpdateUserPicById(@Param("uId") Integer uId,@Param("pic_path") String pic_path);

    // 根据用户id 修改用户名
    @Update("UPDATE user SET username = #{username} where id = #{uId}")
    int updateUsernameById(String username,Integer uId);

    // 根据用户id 修改密码
    @Update("UPDATE user SET password = #{password} where id = #{uId}")
    int updatePasswordById(String password,Integer uId);
}
